diff -Naur surf-2.0/surf.c surf-2.0.patched/surf.c
--- surf-2.0/surf.c	2017-03-28 12:17:45.000000000 -0400
+++ surf-2.0.patched/surf.c	2017-06-25 01:23:41.445168316 -0400
@@ -174,6 +174,7 @@
 static void cleanup(void);
 
 /* GTK/WebKit */
+static GdkDevice *getkbdevice(void);
 static WebKitWebView *newview(Client *c, WebKitWebView *rv);
 static void initwebextensions(WebKitWebContext *wc, Client *c);
 static GtkWidget *createview(WebKitWebView *v, WebKitNavigationAction *a,
@@ -263,7 +264,6 @@
 void
 setup(void)
 {
-	GdkDisplay *gdpy;
 	int i, j;
 
 	/* clean up any zombies immediately */
@@ -281,8 +281,6 @@
 
 	gtk_init(NULL, NULL);
 
-	gdpy = gdk_display_get_default();
-
 	curconfig = defconfig;
 
 	/* dirs and files */
@@ -290,7 +288,7 @@
 	scriptfile = buildfile(scriptfile);
 	cachedir   = buildpath(cachedir);
 
-	gdkkb = gdk_seat_get_keyboard(gdk_display_get_default_seat(gdpy));
+	gdkkb = getkbdevice();
 
 	if (!stylefile) {
 		styledir = buildpath(styledir);
@@ -329,6 +327,23 @@
 	}
 }
 
+static GdkDevice *
+getkbdevice(void)
+{
+	GList *l, *gdl = gdk_device_manager_list_devices(
+	           gdk_display_get_device_manager(gdk_display_get_default()),
+		   GDK_DEVICE_TYPE_MASTER);
+	GdkDevice *gd = NULL;
+
+	for (l = gdl; l != NULL; l = l->next)
+		if (gdk_device_get_source(l->data) == GDK_SOURCE_KEYBOARD)
+			gd = l->data;
+
+	g_list_free(gdl);
+	return gd;
+}
+
+
 void
 sigchld(int unused)
 {
